﻿using IM.Easy.Core.Audit;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.Entity.System
{
    [SugarTable("SysUser")]
    public class SysUser : AuditableEntity, ISystem, IActive
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [SugarColumn(Length = 32, ColumnDescription = "用户名")]
        public string UserName { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(Length = 255, ColumnDescription = "密码")]
        public string Password { get; set; }

        /// <summary>
        /// 昵称
        /// </summary>
        [SugarColumn(Length = 32, ColumnDescription = "昵称")]
        public string NickName { get; set; }

        /// <summary>
        /// 真实姓名
        /// </summary>
        public string? RealName { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        public string? Mobile { get; set; }

        /// <summary>
        /// 电子邮件
        /// </summary>
        public string? Email { get; set; }

        /// <summary>
        /// 是否开通 本地邮箱
        /// </summary>
        public bool LocalEmail { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public int Gender { get; set; }

        /// <summary>
        /// 出生日期
        /// </summary>
        [SugarColumn]
        public DateTime? BirthDay { get; set; }

        /// <summary>
        /// 用户头像
        /// </summary>
        [SugarColumn(Length = 256)]
        public string? Avatar { get; set; }

        /// <summary>
        /// 部门ID
        /// </summary>
        public long DeptId { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        [SugarColumn]
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 创建方式【系统内置，管理员分配，Gitee登录创建...】
        /// </summary>
        public string? CreationSource { get; set; }


        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(Length = 256)]
        public string? Remark { get; set; }

        /// <summary>
        /// 是否系统内置
        /// </summary>
        [SugarColumn(IsNullable = false)]
        public bool IsSystem { get; set; }

        /// <summary>
        /// 启用状态
        /// </summary>
        [SugarColumn(DefaultValue = "1")]
        public bool IsActive { get; set; }

        /// <summary>
        /// 岗位ID
        /// </summary>
        [SugarColumn(ColumnDescription = "岗位ID")]
        public long? PostId { get; set; }

        /// <summary>
        /// 所在部门
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(DeptId))]
        public SysDepartment Department { get; set; }

        /// <summary>
        /// 所有角色列表
        /// </summary>
        [Navigate(typeof(SysUserRole), nameof(SysUserRole.UserId), nameof(SysUserRole.RoleId))]
        public List<SysRole> Roles { get; set; }

        /// <summary>
        /// 所在部门
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(PostId))]
        public SysPost Post { get; set; }

        /// <summary>
        /// 账户安全表
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(Id), nameof(SysAccountSecurity.UserId))]
        public SysAccountSecurity Security { get; set; }

    }
}
